<script type="text/javascript">
    $(document).ready(function() {
        // date picker
        $(".tanggal").datepicker({ 
            target: 'tanggal',
            changeMonth: true,
            changeYear: true,
            showOn: 'both',
            buttonImage: '{$BASEURL}/resource/doc/images/icon/calendar.gif',
            buttonImageOnly: true,
            dateFormat: 'yy-mm-dd'
        });
        
        $('#date-picker').change(function(){
            hitung_masa_penyusutan();
        });
        
        // hitung masa berlaku
        function hitung_masa_penyusutan(){
            // ajax loader
            $("#loader").ajaxStart(function(){
                $('#expired_date_label').hide();
                $(this).show();
            });
            $("#loader").ajaxStop(function(){
                $(this).hide();
                $('#expired_date_label').show();
            });
            // input
            var tanggal = $( "#date-picker" ).val(); 
            // ajax
            $.ajax({
                type:'POST',
                data:'tanggal='+tanggal,
                url:'{$config->site_url("inventarisasi/penyusutan/hitung_masa_penyusutan/")}',
                success : function(result){
                    $('#expired_date').val(result);
                    $('#expired_date_label').text(result);
                }
            });
        }
    });
</script>
<div class="breadcrum">
    <p>
        <a href="#">Inventarisasi</a>
        <span></span><small>Penyusutan</small> 
    </p>
    <div class="clear"></div>
</div>

<div class="sub-content">
    <!-- notification template -->
    {include file="base/templates/notification.html"}
    <!-- end of notification template-->  
    <div class="search-box">
        <h3><a href="#">Pencarian</a></h3>
        <form action="{$config->site_url('inventarisasi/penyusutan/detail')}" method="post">
            <table width="100%" border="0" class="table-search">
                <tbody>
                    <tr>
                        <th width="15%">Tahun</th>
                        <td width="15%">
                            <select name="tahun">
                                <option value=""></option>
                                {foreach from=$rs_tahun key=no item=result}
                                    <option value="{$result.tahun|default:''}">{$result.tahun|default:''}</option>
                                {/foreach}
                            </select>
                        </td>
                        <td>
                            <input type="submit" class="submit" name="save" value="Tampilkan">
                            <input type="submit" class="submit" name="save" value="Reset">
                        </td> 
                    </tr>  
                </tbody>
            </table>
        </form>
    </div> 
</div> 
<div class="sub-content">
    <div class="navigation"> 
        <div class="pageRow">
            <div class="pageNav">
                <ul>
                    <li class="info"><strong>{$pagination.start|default:'0'} - {$pagination.end|default:'0'}</strong> dari <strong>{$pagination.total|default:'0'}</strong> Data</li>
                    {$pagination.data|default:''}
                </ul>
            </div>
            <div class="clear"></div>
        </div>   
        <div class="navigation-button">
            <ul>
                <li><a href="{$config->site_url({'inventarisasi/penyusutan/add/'})}"><img src="{$BASEURL}/resource/doc/images/icon/add-icon.png" alt="">Penyusutan</a></li>
                <li><a href="{$config->site_url({'inventarisasi/penyusutan/'})}"><img src="{$BASEURL}/resource/doc/images/icon/printer-icon.png" alt="">Daftar Data</a></li> 
            </ul>
            <div class="clear"></div>
        </div>
    </div> 
    <table width="100%" class="table-view">
        <tbody>
            <tr>
                <th width="5%">No</th>
                <th width="15%">Tanggal</th> 
                <th width="75%">Keterangan</th>
                <th width="10%"></th>
            </tr>  
            {assign var='numb' value={$pagination.start}}
            {foreach from=$rs_id key=no item=result}
            <tr {if ($no % 2) <> 0}class="blink-row"{/if}>  
                <td>{$numb++}</td>
                <td>{$dtm->get_full_date($result.penyusutan_tgl|default:'')}</td>
                <td>{$result.penyusutan_keterangan}</td>
                <td align='center'>
                    <a href="{$config->site_url('inventarisasi/penyusutan/konfirmasi')}/{$result.penyusutan_id}" class="button-distribusi">Detail</a>
                </td>
            </tr>
            {foreachelse}
            <tr>
                <td colspan="4">Data masih kosong</td>
            </tr>
            {/foreach}
        </tbody>
    </table>  
</div>